<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/wondershare/js/jquery.js"></script> 
<script src="/wondershare/js/products.js"></script> 
<link href="/wondershare/styles/main.css" rel="stylesheet" type="text/css" />
<link href="/wondershare/styles/general.css" rel="stylesheet" type="text/css" />
<script src="/wondershare/js/jquery.cvbox.min.js"></script> 

<script type="text/javascript">  
function on_radio()
{
 $('input[name="productlist"]').each(function () {
	 $(this).attr('checked','');
	}); 
 
}
function select_tag(str,id)
{
   $('input[name="tag[]"]').each(function () {
	 $(this).attr('checked','');
	}); 
   var strs= new Array(); //定义一数组
   strs=str.split(","); //字符分割 
   for (i=0;i<strs.length ;i++ )    
   {
  
	  $('input[name="tag[]"]').each(function () {

	   if($(this).val() == strs[i] )
	   {
	  
	    $(this).attr('checked','checked');
	   }
  	  
       }); 
   }
  $(".A4Demo").cvbox(
	{
       titleBarText: "选择tag"
   });
   $('#A4Demo2').show();
   $("#check_topic").click( function () { check_tag(id) }); 
} 

function  check_tag(id)
{
  var tag_str = '';
  var web_type = $("#web_type").val();
  $('input[name="tag[]"]').each(function () {
  if ($(this).attr('checked')) 
  {
     tag_str = tag_str + $(this).val()+',';
  }
  });
  $.get("/wondershare/products.php?action=index", { in_jax: 1, tag_str:tag_str,p_id:id ,type:'update_tag'},
  function(data){
	$('#A4Demo2').hide();
	$("#cvBoxTitleBarClose").click();	
	$("#check_topic").unbind("click") ;
	 window.location.href="/wondershare/products.php?action=index&web_type="+web_type;
  });
  

}

<{if $type == 1}>
    $(function(){
	<{foreach from=$product_listdata item=data  }>
	  $('input[name="productlist[]"]').each(function () {

	   if($(this).val() == '<{$data}>' )
	   {
	  
	    $(this).attr('checked','checked');
	   }
  	  
       }); 

	<{/foreach}>
	});
	
	function get_checked_product()
	{
		var id = new Array();
		$('input[name = "productlist[]"]:checked').each(function(){
			id.push(this.value);
		});
	
		return id.join(",");
	}
	
	function get_checked_product_name()
	{
		var name = new Array();
		$('input[name = "productlist[]"]:checked').each(function(){

			name.push($(this).attr('title'));
		});

		return name.join(",\n");
	}
<{/if}>


<{if $type == 2}>
    $(function(){
	   $("#product_id"+<{$product_listdata}>).attr("checked","checked");
	});
	
	function get_checked_product()
	{
		var id = $('[name = productlist]:checked').val();
		
		return id;
	}
	
	function get_checked_product_name()
	{
		var name = $('[name = productlist]:checked').attr('title');
		
		return name;
	}
<{/if}>

//note 排序
function _sort( field ){
	$("#sortby").val( field );
	if( $("#sort").val() == 'ASC' ) $("#sort").val('DESC'); else $("#sort").val('ASC');
	$("#myform").submit();
}

//note 生成HTML
//产品单页的三个字段
var table_2 = '<{$site_config.table_2}>';
var field_id_2 = '<{$site_config.field_id_2}>';
var default_id = '<{$site_config.default_id}>';

var danye = false;
function createHtml( table, field_id, key_id ){
	$("#create_tip_"+key_id).html( '正在生成...' );
	var d = danye ? default_id : 0;
	
	var url = '../bin/docList_'+table+'.php?action=pub&TID='+table+'&field_id='+field_id+'&key_id='+key_id+'&default_id='+d+'&ajax_pub=1';
	$.get(url,function(data){					
		if( parseInt(data) == 1 ){
			$("#create_tip_"+key_id).html( '生成成功' );

		}else if( data == 'empty' ){
			if( table_2 ){
				danye = true;
				createHtml( table_2, field_id_2, key_id );
			}else{
				document.location.href = '../bin/doc_'+table_2+'.php?field_id='+field_id_2+'&key_id='+key_id;
			}
		}else{
			document.location.href = '../bin/doc_'+table+'.php?field_id='+field_id+'&key_id='+key_id;
		}
	});
}

function _createHtml( table, field_id, table_3, field_id_3, key_id ){
	createHtml( table, field_id, key_id );
	createHtml( table_3, field_id_3, key_id );
}
</script>
<style type="text/css">
catListTag {
	DISPLAY: none
}
.cvBoxShade {
	Z-INDEX: 2000; BACKGROUND: #ccc; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 0px
}
.cvBoxBorder {
	BORDER-RIGHT: #000000 0px solid; PADDING-RIGHT: 8px; BORDER-TOP: #000000 0px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; Z-INDEX: 2000; PADDING-BOTTOM: 8px; BORDER-LEFT: #000000 0px solid; WIDTH: 100%; PADDING-TOP: 8px; BORDER-BOTTOM: #000000 0px solid; POSITION: absolute; BACKGROUND-COLOR: #ccc
}
.cvBoxBorder A {
	COLOR: #486aaa; TEXT-DECORATION: none
}
.cvBoxBorder A:hover {
	COLOR: #c00; TEXT-DECORATION: none
}
.cvBoxTitleBar {
	WIDTH: 100%; LINE-HEIGHT: 27px; HEIGHT: 26px; BACKGROUND-COLOR: #eeeeee
}
.cvBoxTitleBarText {
	PADDING-LEFT: 10px; FONT-WEIGHT: bold; FLOAT: left; COLOR: #333
}
.cvBoxTitleBarClose {
	PADDING-RIGHT: 10px; FLOAT: right; COLOR: #3867af; FONT-FAMILY: Verdana
}

.cvBoxBody {
	WIDTH: 100%; BACKGROUND-COLOR: #ffffff
}

</style>
</head>
<body >

<{if $type == 0}> 
<h1>

<span class="action-span">
<a href="/wondershare/products.php?action=index&act=add&web_type=<{$web_type}>">添加产品</a>
</span>
<span class="action-span1">
<a href="#"><{$web_info}>网站产品信息</a>
</span>
<span id="search_id" class="action-span1">  &nbsp;&nbsp;> &nbsp;&nbsp;产品列表 </span>
<div style="clear:both"></div>
</h1>
<{/if}>

<form id="myform" name="myform" method="POST" action="/wondershare/products.php?action=index">
    <img height="22" border="0" width="26" alt="SEARCH" src="images/icon_search.gif">
        <!-- 分类 -->
        主分类：<select name="cat_id" style="width:150px;"><option value="0">所有分类</option>
	<{if $cat_select_s == "" }>
	<{$cat_select}>
	<{else}>
	<{$cat_select_s}>
	<{/if}>
	</select>
	 <!-- 产品标签 -->
    &nbsp;&nbsp;产品标签：<select name="tag" style="width:80px;"><option value="">所有</option>
	<option value="New" <{if $tag == "New" }> selected="selected" <{/if}> >New</option>
	<option value="Free" <{if $tag == "Free" }> selected="selected" <{/if}> >Free</option>
	<option value="Upgrade" <{if $tag == "Upgrade" }> selected="selected" <{/if}> >Upgrade</option>
	<option value="Top Seller" <{if $tag == "Top Seller" }> selected="selected" <{/if}> >Top Seller</option>
	<option value="Top Downloader" <{if $tag == "Top Downloader" }> selected="selected" <{/if}> >Top Downloader</option>
	</select>
	<!-- 重要性 -->
    &nbsp;&nbsp;重要级别：<select name="is_emphasis"><option value="0">所有</option>
	<option value="1"  <{if $is_emphasis == 1 }> selected="selected" <{/if}> >重要</option>
	<option value="2" <{if $is_emphasis == 2 }> selected="selected" <{/if}> >次要</option>
	</select>
    &nbsp;&nbsp;
    <{$web_info}> 产品ID OR  公共产品ID<input type="text" size="6" name="pr_id" value="<{$pr_id}>"/>
        <!-- 关键字 -->
    &nbsp;&nbsp;
    产品名称：<input type="text" size="25" name="pr_name" value="<{if $pr_name == '' }>输入产品名称<{else}><{$pr_name|escape}><{/if}>" onblur="if(this.value=='')this.value='输入产品名称';" onclick="if(this.value=='输入产品名称')this.value=''"  style="margin-right:10px;">
	<input type="hidden"  name="type" value="<{$type}>" >
	<input type="hidden" name="product_list" value="<{$product_list}>" />
	<input type="hidden" name="products_id" value="<{$products_edit_id}>" />
    <input type="hidden" name="sortby" id="sortby" value="<{$sortby}>" />
    <input type="hidden" name="sort" id="sort" value="<{$sort}>"/>
    <input type="hidden" name="web_type" id="web_type" value="<{$web_type}>"/>
    <input type="submit" class="button"  name="search" value=" 搜索 ">

</form>
<table width="100%" cellspacing="1" cellpadding="2" id="list-table" class="list-div">
<tbody>
  <tr>
  <{if $type == 0}> <th width="80"><a href="javascript:_sort('id');"><{$web_info}>产品ID</a><{if $sortby == 'id' }><img src="../images/<{if $sort == 'DESC'}>down<{else}>up<{/if}>.gif" /><{/if}></th> <{/if}>
   <th >公共产品ID</th>
   <{if $type == 0}> <th width="80"><a href="javascript:_sort('product_cbsid');">CBS产品ID</a><{if $sortby == 'product_cbsid' }><img src="../images/<{if $sort == 'DESC'}>down<{else}>up<{/if}>.gif" /><{/if}></th> <{/if}>
   <{if $type == 1 || $type == 2}> <th >选择</th> <{/if}>
    <th>产品名称</th>
	<th><a href="javascript:_sort('sort');">排序</a><{if $sortby == 'sort' }><img src="../images/<{if $sort == 'DESC'}>down<{else}>up<{/if}>.gif" /><{/if}></th>
	<th>产品标签</th>
	<th>产品重要级别</th>
	<th><a href="javascript:_sort('won_product_update_user');">操作人员</a><{if $sortby == 'won_product_update_user' }><img src="../images/<{if $sort == 'DESC'}>down<{else}>up<{/if}>.gif" /><{/if}></th>
    <th><a href="javascript:_sort('won_product_update_time');">最后操作时间</a><{if $sortby == 'won_product_update_time' }><img src="../images/<{if $sort == 'DESC'}>down<{else}>up<{/if}>.gif" /><{/if}></th>
    <{if $type == 0}>
	<th>页面管理</th>
	<th>操作</th>
	<{/if}>

  </tr>
  <{foreach from=$products_info item=products}>
  <{if $products.id !=$products_edit_id }>
  <tr align="center"  id="tr_<{$products.id}>">
   <{if $type == 0}>  <td width="5%" align="center"  >
	<input value="<{$products.id}>" name="ID[]" type="checkbox" > <{$products.id}></td><{/if}>
	   <td width="5%" align="center"  >
	<{$products.product_id}></td>
    
   <{if $type == 0}>  <td width="5%" align="center"  >
	<{$products.product_cbsid}></td><{/if}>
	
	<{if $type == 1}>  <td width="5%" align="center"  >
	<input type="checkbox"  title="<{$products.product_name}>" name="productlist[]"  value="<{$products.id}>"><{$products.id}>
	</td>
	<{/if}>
	<{if $type == 2}>
	<td width="5%" align="center"  >
	<input type="radio" name="productlist"  title="<{$products.product_name}>" id="product_id<{$products.id}>" value="<{$products.id}>" ><{$products.id}>
	</td>
	<{/if}>
	
	<td width="21%" align="left" >
	<{$products.product_name}>
	</td>
	
	
    <td width="5%" align="center" id="td_sort_<{$products.id}>">
	<span   onmouseout='check_css("sort_<{$products.id}>",0);' onmouseover='check_css("sort_<{$products.id}>",1);'      
	onclick='check_info("<{$products.id}>","sort_<{$products.id}>","td_sort_<{$products.id}>","60","p_sort");'  id="sort_<{$products.id}>" ><{$products.sort}></span>
	
	</td>
	
	<td width="15%" align="center">
	<{if $type == 0}>  <a id="A4_<{$products.id}>" href="javascript:void(0);" onclick = "select_tag('<{$products.tag}>',<{$products.id}>)" >
	<{if $products.tag != ''}> <{$products.tag}> <{else}> 没有相关标签<{/if}> </a>  <{/if}>
	<{if $type == 1}> <{if $products.tag != ''}> <{$products.tag}> <{else}> 没有相关标签<{/if}> <{/if}>

	</td>

	<td width="5%" align="center" > 

	<{if $products.is_emphasis == 1}> 重要 <{else}>次要<{/if}>
	</td>
	<td width="5%" align="center">
    <{if $products.won_product_update_user != ''}>  <{$products.won_product_update_user}> <{else}> <{$products.won_product_add_user}> <{/if}>
	</td>
	<td width="10%" align="center">
    <{if $products.won_product_update_time != ''}>  <{$products.won_product_update_time}> <{else}> <{$products.won_product_add_time}> <{/if}>
	</td>

	<{if $type == 0}><td width="5%" align="center"><a href="/wondershare/products_page.php?action=index&ws_products_id=<{$products.id}>&web_type=<{$web_type}>">页面管理</a></td><{/if}>
	
    <{if $type == 0}>  <td width="10%" align="center">
    <a href="#" onclick="{if(confirm('确定要删除记录吗?')){delete_info(<{$products.id}>,'tr_<{$products.id}>','del');}return false;}" >删除</a> | 
	<a href="/wondershare/products.php?action=index&act=edit&p_id=<{$products.id}>&web_type=<{$web_type}>" > 编辑 </a>|
    
    <span id="create_tip_<{$products.id}>"><a href="javascript:_createHtml(<{$site_config.table}>,<{$site_config.field_id}>,<{$site_config.table_3}>,<{$site_config.field_id_3}>,<{$products.id}>);">生成</a></span>
    </td><{/if}>

  </tr>
  <{/if}>
  <{/foreach}>
  
  <tr>
	    <{if $type == 0}> <td align="center"><input name="checkall" value="checked" onclick="v=document.getElementsByName('ID[]');if(this.checked){for(i=0;i<v.length;i++)v[i].checked=true;}else{for(i=0;i<v.length;i++)v[i].checked=false;}" type="checkbox">全选</td> 
		<{else}><td></td><{/if}>

		<td colspan="9">&nbsp;&nbsp;<{if $type == 0}> <input name="sub" value="删除" type="button" onclick="delete_product(0,'list','del_products');">
		<{elseif $type == 2 && $total>0}><input name="sub" value="取消选择" type="button" onclick="on_radio();"><{/if}>&nbsp;&nbsp;&nbsp;&nbsp;<{$page_url}> &nbsp; 共有 <span id="total"><{$total}></span>条记录</td>	
	</tr>
  </tbody>
</table>

<!--<div style="margin-left:15px; margin-top:20px;" ><{$page_url}> &nbsp;&nbsp;&nbsp; 共有 <span id="total"><{$total}> </span>条记录</div>	-->

<div class="A4Demo" style="display: none; width: 550px; padding: 10px;"  id="A4Demo">
   <div id="A4Demo2">
       <input type="checkbox" title="Free" value="Free" name="tag[]">Free &nbsp;&nbsp;
	   <input type="checkbox" title="Upgrade" value="Upgrade" name="tag[]">Upgrade &nbsp;&nbsp;
	   <input type="checkbox" title="New" value="New" name="tag[]">New &nbsp;&nbsp;
	   <input type="checkbox" title="Top Seller" value="Top Seller" name="tag[]">Top Seller &nbsp;&nbsp;
		<input type="checkbox" title="Top Downloader" value="Top Downloader" name="tag[]">Top Downloader &nbsp;&nbsp;
	   <input type="button"    value="确定"  name="check_topic"  id="check_topic"   style="margin-top:20px; margin-left:200px;">
	   
    </div>
   </div>

</body>
</html>